﻿/// <summary>
/// LogHelper 的摘要说明
/// </summary>
public class LogHelper
{
    //private static string LOGPATH = HostingEnvironment.MapPath("~") + "\\log\\";

    /// <summary>
    /// log4net 记录日志
    /// </summary>
    /// <param name="log">日志内容</param>
    public static void Log(string msg)
    {
        #region IO记录
        //if (!Directory.Exists(LOGPATH))
        //{
        //    Directory.CreateDirectory(LOGPATH);
        //}

        //string logPath = LOGPATH + "log.txt";
        //if (!File.Exists(logPath))
        //{
        //    File.Create(logPath).Close();
        //}

        //using (StreamWriter sw = new StreamWriter(logPath, true, Encoding.UTF8))
        //{
        //    sw.WriteLine("------------" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "------------");
        //    sw.WriteLine(log);
        //    sw.WriteLine("----------------------------------------");
        //    sw.Close();
        //}
        #endregion

        log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().Name);
        log.Error(msg);
    }

    /// <summary>
    /// log4net 记录日志(微信日志)
    /// </summary>
    /// <param name="className">类名</param>
    /// <param name="msg">日志内容</param>
    public static void Log(string className, string msg)
    {
        log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().Name);
        log.Error(className + "--" + msg);
    }
}